package com.wechat.user.controller;

import com.wechat.common.web.result.Result;
import com.wechat.user.request.LoginPhoneRequest;
import com.wechat.user.response.LoginResponse;
import com.wechat.user.service.LoginService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/login")
@Tag(name = "用户登录", description = "用户登录")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping("/phone")
    @Operation(
            summary = "用户手机号登录",
            description = "用户手机号登录"
    )
    public Result<LoginResponse> loginPhone(@Validated @RequestBody LoginPhoneRequest request) {
        LoginResponse response = loginService.loginPhone(request);
        return Result.success(response);
    }


}
